﻿#pragma once

#include "../../MirControls/MirImageControl.h"
#include "../../../Shared/Data/ItemData.h"
#include "../../MirControls/MirItemCell.h"
#include "../../MirControls/MirLabel.h"
#include "../../MirControls/MirButton.h"
#include <string>
#include "../../../stringhelper.h"

using namespace Client::MirControls;
using namespace Client::MirGraphics;
using namespace Client::MirNetwork;
using namespace Client::MirSounds;

namespace C = ClientPackets;

namespace Client::MirScenes::Dialogs
{
    class ItemRentingDialog final : public MirImageControl
    {
    public:
        static UserItem *RentalItem;

        MirItemCell *const ItemCell;
        unsigned int RentalPeriod = 0;

    private:
        MirLabel *const _nameLabel, *const _rentalPeriodLabel;
        MirButton *const _lockButton, *const _setRentalPeriodButton, *const _confirmButton;

    public:
        virtual ~ItemRentingDialog()
        {
            delete ItemCell;
            delete _nameLabel;
            delete _rentalPeriodLabel;
            delete _lockButton;
            delete _setRentalPeriodButton;
            delete _confirmButton;
        }

        ItemRentingDialog();

    private:
        static void CancelItemRental();

    public:
        void EnableConfirmButton();

        void InputRentalPeroid();

        void RefreshInterface();

        void OpenItemRentalDialog();

        void Reset();

        void Lock();

    private:
        void Unlock();
    };

    class GuestItemRentingDialog final : public MirImageControl
    {
    public:
        static UserItem *GuestLoanItem;

        unsigned int GuestRentalPeriod = 0;

    private:
        MirLabel *const _nameLabel, *const _rentalPeriodLabel;
        MirButton *const _lockButton, *const _setRentalPeriodButton, *const _confirmButton;
        std::string _guestName;

        MirItemCell *_guestItemCell;

    public:
        virtual ~GuestItemRentingDialog()
        {
            delete _nameLabel;
            delete _rentalPeriodLabel;
            delete _lockButton;
            delete _setRentalPeriodButton;
            delete _confirmButton;
            delete _guestItemCell;
        }

        GuestItemRentingDialog();

        void RefreshInterface();

        void Reset();

        void SetGuestName(const std::string &name);

        void Lock();

    private:
        void Unlock();
    };
}
